package com.glsx.core.service;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.data.domain.Sort.Direction;

import java.io.Serializable;
import java.util.List;

public interface BaseService<T, ID extends Serializable>{
	
	T save(T entity);
	Iterable<T> save(Iterable<T> entities);
	
	T findOne(ID id);
	List<T> findAll();
	List<T> findAll(Iterable<ID> ids);
	
	Page<T> findByAuto(T example,Pageable pageable);
	Page<T> findByAuto(T example,Integer page, Integer pageSize,Sort sort);
	Page<T> findByAuto(T example,Integer page, Integer pageSize,Direction direction,String ... fieldNames);
	
	boolean exists(ID id);
	
	void delete(ID id);
	void delete(T entity);
	void deleteInBatch(Iterable<T> entities);
	void deleteAllInBatch();
	
}
